<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>意达设计</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/dealer.css"/>
</head>
<body class="body">

<!-- header -->
<div class="pageheader"><a href="javascript:void(0);" onclick="api.closeWin();" class="return"></a><span>修改密码</span></div>

<!-- contact -->
<div class="pad">
    <div class="forpw"><input type="text" placeholder="请输入旧密码" name="old_pwd"></div>
    <div class="forpw"><input type="text" placeholder="请输入新密码" name="new_pwd"></div>
    <div class="forpw"><input type="text" placeholder="请再次输入新密码" name="re_pwd"></div>
    <div class="logBnt"><input type="button" value="确认新密码" onclick='xgpwd()'></div>
</div>



</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../script/adaptive.js"></script>
<script type="text/javascript" src="../script/tabs.js"></script>
<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();

    apiready = function () {
        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });
        //api.showProgress();

    };
    
   
    function xgpwd() {
        var old_pwd=$("input[name=old_pwd]").val();
        var new_pwd=$("input[name=new_pwd]").val();
        var re_pwd=$("input[name=re_pwd]").val();
        
        if(old_pwd==''){
            api.alert({msg:"请输入原密码！"});return;
        }
        
        if(new_pwd==''){
            api.alert({msg:"请输入新密码！"});return;
        }else if(!/^[a-zA-Z\d_]{6,}$/.test(new_pwd)){
            api.alert({msg:"新密码不合法！"});return;
        }else if(new_pwd != re_pwd){
            api.alert({msg:"两次密码不一致！"});return;
        }
        

        p={token:token,old_pwd:old_pwd,new_pwd:new_pwd};

        api.ajax({
            url: webSiteUrl+'/app/user/edit_pwd',
            method: 'post',
            data: {
                values:p,
            }
        }, function(ret, err) {
            api.hideProgress();
            
            if(ret.code==200){
                
                api.openWin({
                    name: 'selectaddName',
                    url: './usercenter.html',
                    pageParam: {
                        
                    }
                });
            }else{
                alert(ret.msg)
            }

        });
        
    }
</script>

</html>
